package com.easyshopping.domain;

import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class ShoppingList {

	public static final String SL = "SHOPPINGLIST";
    public static final String SL_ID = "_id";
    public static final String SL_NAME = "NAME";
    public static final String SL_CREATION = "CREATION";
	
	private int id;
	
	private String name;
	
	private Date creationTime;
	
	private List<Item> items;

	public ShoppingList(String name) {
		this.name = name;
		
//		SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm");
//		this.creationTime = sdf.format(Calendar.getInstance().getTime());
		
		this.creationTime = Calendar.getInstance().getTime();
		
		items = new ArrayList<Item>();
	}

	public ShoppingList() {
		
		this.creationTime = Calendar.getInstance().getTime();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		this.name = "Shopping List " + sdf.format(creationTime);
		
//		sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm");
//		this.creationTime = sdf.format(Calendar.getInstance().getTime());
		
		items = new ArrayList<Item>();
	}
	
	public ShoppingList(int id, String name) {
		
		this.setId(id);
		this.setName(name);
		
		items = new ArrayList<Item>();
	}
	
	public void addItem(Item item) {
		this.getItems().add(item);
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getCreationTime() {
		return creationTime;
	}

	public List<Item> getItems() {
		return items;
	}

	public void setItems(List<Item> items) {
		this.items = items;
	}
	
}
